using System;
using System.Windows;
using System.Windows.Controls;

namespace MainView.TemplateSelector
{
	public class ColumnTemplateSelector : DataTemplateSelector
	{
		public override DataTemplate SelectTemplate(object item, DependencyObject container)
		{
			Column column = item as Column;
			if (column != null)
			{
				try
				{
					object obj = ((Control)container).FindResource(string.Concat(column.Settings, "ColumnTemplate"));
					if (obj != null && obj is DataTemplate)
					{
						return (DataTemplate)obj;
					}
				}
				catch (Exception)
				{
				}
			}
			return base.SelectTemplate(item, container);
		}
	}
}
